using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using IGlobalist.Cms.Model;
using IGlobalist.Cms.Common;

namespace IGlobalist.Cms.Admin.Control
{
    public partial class ContentClassList : AdminBaseUserControl
    {
        public event EventHandler SelectedClassChanged;

        #region Properties
        public string SelectedValue
        {
            get { return Convert.ToString(ViewState["ClassID"]); }
            set { ViewState["ClassID"] = value; }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void DoHidden(object sender, EventArgs e)
        {
            this.Visible = false;
        }
        public void DoShow(object sender, EventArgs e)
        {
            this.Visible = true;
        }
        public override void DataBind()
        {
            base.DataBind();
            IList<CmsClass> classList = (IList<CmsClass>)ViewState["_classList"];
            gvClassList.DataSource = classList;
            gvClassList.DataBind();
        }



        public IList<CmsClass> DataSource
        {
            set { ViewState["_classList"] = value; }
        }        

        protected void btnChoice_Click(object sender, EventArgs e)
        {
            Button btnChoice = (Button)sender;
            long ID = Convert.ToInt64(btnChoice.CommandArgument);
            Session[SessionVariable.Clazz.CurrentID] = ID;
            if (SelectedClassChanged != null)
            {
                SelectedClassChanged(this, e);
            }
        }        
    }
}